package com.topvision.myviewtest.mvp.demo1;

import com.topvision.myviewtest.mvp.bean.WeatherBean;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * @author lucy
 * @description 持有M层和V层
 * @date 2017-12-11 14:18
 */

public class RequestPresenter1 {

    private RequestModel1 mRequestModel;
    private RequestView1 mRequestView;

    public RequestPresenter1(RequestView1 requestView) {
        mRequestView = requestView;
        mRequestModel = new RequestModel1();
    }

    public void clickRequest(String cityId) {
        mRequestView.requestLoading();
        mRequestModel.request(cityId, new Callback<WeatherBean>() {
            @Override
            public void onResponse(Call<WeatherBean> call, Response<WeatherBean> response) {
                mRequestView.requestSuccess(response.body());
            }

            @Override
            public void onFailure(Call<WeatherBean> call, Throwable t) {
                mRequestView.requestFailure(t.toString());
            }
        });

    }
}
